//
//  QianYueCell.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/13.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "QianYueCell.h"

@implementation QianYueCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self createUI];
        UIImageView *lineImg = [[UIImageView alloc] init];
        lineImg.backgroundColor = [UIColor orangeColor];
        [self addSubview:lineImg];
        [lineImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(4, 80));
            make.left.mas_equalTo(self.mas_left).offset(10);
            make.top.equalTo(self.mas_top).offset(7);
        }];
        //头像
        _imgView = [[UIImageView alloc] init];
        // _imgView.backgroundColor = [UIColor redColor];
        _imgView.image = [UIImage imageNamed:@"nanshihui"];
        [self addSubview:_imgView];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(15, 16));
            make.left.equalTo(lineImg.mas_left).offset(10);
            make.top.equalTo(self.mas_top).offset(8);
        }];
        
        //客户姓名
        _nameLab = [[UILabel alloc] init];
        _nameLab.textColor = OverColor;
        _nameLab.font = [UIFont systemFontOfSize:14];
        _nameLab.textAlignment = NSTextAlignmentLeft;
        _nameLab.text = @"王晨曦";
        // _nameLab.backgroundColor = [UIColor yellowColor];
        [self addSubview:_nameLab];
        [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(60, 18));
            make.left.equalTo(_imgView.mas_right).offset(8);
            make.top.equalTo(self.mas_top).offset(8);
        }];
        
        //认购时间
        _renShiLab = [[UILabel alloc] init];
        _renShiLab.text = @"认购日期 | 2016-12-29";
        _renShiLab.font = [UIFont systemFontOfSize:10];
        _renShiLab.textColor = [UIColor blackColor];
        [self addSubview:_renShiLab];
        [_renShiLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(150, 16));
            make.left.equalTo(_nameLab.mas_right).offset(15);
            make.top.equalTo(self.mas_top).offset(10);
        }];
        
        //认购房源
        _renFangLab = [[UILabel alloc] init];
        _renFangLab.text = @"认购房源 | 7号楼3单元1907房";
        _renFangLab.font = [UIFont systemFontOfSize:10];
        _renFangLab.textColor = [UIColor blackColor];
        [self addSubview:_renFangLab];
        [_renFangLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(180, 16));
            make.left.equalTo(self.mas_left).offset(40);
            make.top.equalTo(self.mas_top).offset(30);
        }];
        //付款方式
        _fuStlyLab = [[UILabel alloc] init];
        _fuStlyLab.text = @"付款方式 | 按揭支付";
        _fuStlyLab.font = [UIFont systemFontOfSize:10];
        _fuStlyLab.textColor = [UIColor blackColor];
        [self addSubview:_fuStlyLab];
        [_fuStlyLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(110, 16));
            make.left.equalTo(self.mas_left).offset(40);
            make.top.equalTo(self.mas_top).offset(50);
        }];
        //首付状态
        _shouFuLab = [[UILabel alloc] init];
        _shouFuLab.text = @"首付状态 | 已交清";
        _shouFuLab.font = [UIFont systemFontOfSize:10];
        _shouFuLab.textColor = [UIColor blackColor];
        [self addSubview:_shouFuLab];
        [_shouFuLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(110, 16));
            make.left.equalTo(_fuStlyLab.mas_right).offset(5);
            make.top.equalTo(self.mas_top).offset(50);
        }];
        
        //代收费用状态
        _moneyStyleLab = [[UILabel alloc] init];
        _moneyStyleLab.text = @"代收费用状态 | 未交清";
        _moneyStyleLab.font = [UIFont systemFontOfSize:10];
        _moneyStyleLab.textColor = [UIColor blackColor];
        [self addSubview:_moneyStyleLab];
        [_moneyStyleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(180, 16));
            make.left.equalTo(self.mas_left).offset(40);
            make.top.equalTo(self.mas_top).offset(70);
        }];
              //打电话按钮
        _callBtn = [[UIButton alloc] init];
        [_callBtn setBackgroundImage:[UIImage imageNamed:@"dianhuatubiao"] forState:0];
        [_callBtn addTarget:self action:@selector(callDiBtnClick:) forControlEvents:UIControlEventTouchUpInside];
             _callBtn.mm_acceptEventInterval = 10;
        [self addSubview:_callBtn];
        [_callBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(25);
            make.left.equalTo(self.mas_right).offset(-50);
            make.top.equalTo(self.mas_top).offset(30);
        }];
        
        //电话号码
        _phoneNumber = [[UILabel alloc] init];
        [self addSubview:_phoneNumber];
        
    }
    return self;
}

-(void)setUpQianYUeCellWithName:(NSString *)_name withGouDate:(NSString *)_date withGouHouse:(NSString *)_house withPay:(NSString *)_pay withShouState:(NSString *)_shou withDaiPay:(NSString *)_dai withPhone:(NSString *)_phone
{
    _nameLab.text = _name;
    _renShiLab.text = [NSString stringWithFormat:@"认购日期 | %@",_date];
    _renFangLab.text = [NSString stringWithFormat:@"认购房源 | %@",_house];
    _fuStlyLab.text = [NSString stringWithFormat:@"付款方式 | %@",_pay];
    _shouFuLab.text = [NSString stringWithFormat:@"首付状态 | %@",_shou];
    _moneyStyleLab.text = [NSString stringWithFormat:@"代收费用状态 | %@",_dai];
    _phoneNumber.text = _phone;
}
-(void)callDiBtnClick:(UIButton *)btn
{
    NSMutableString *str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_phoneNumber.text];
    UIWebView *callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    [self addSubview:callWebview];
}

- (void)createUI{
    //创建一个UIView比self.contentView小一圈
    self.bgView  = [[UIView alloc] initWithFrame:CGRectMake(10,4, SCREEN_WIDTH-10*2, 84)];
    self.bgView.backgroundColor = [UIColor whiteColor];
    //给bgView边框设置阴影
    self.bgView.layer.shadowOffset = CGSizeMake(2,2);
    self.bgView.layer.shadowOpacity = 0.3;
    self.bgView.layer.shadowColor = [UIColor blackColor].CGColor;
    [self.contentView addSubview:self.bgView];
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
